import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    transitionName: "slide-left",
    hasLogined: localStorage.getItem("token") != "" ? true : false,
    isFullPage: false, //是否全屏
  },
  mutations: {
    setTransitionName: (state, data) => {
      state.transitionName = data;
    },
    setFullPage: (state, data) => {
      state.isFullPage = data;
    },

    setHasLogined: (state, data) => {
      state.hasLogined = true;
      state.isFullPage = false;
    },
  },
  getters: {
    getTransitionName: (state) => state.transitionName,
    getHasLogined: (state) => state.hasLogined,
    getIsFullPage: (state) => state.isFullPage,
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
      reducer(val) {
        return val;
      },
    }),
  ],
});
